package com.lockmem.setting;

import com.lockmem.Conf.ConfValue;
import com.lockmem.DB.RowUserData;
import com.lockmem.ctrl.CtrlService;
import com.lockmem.listener.ListenerService;
import com.lockmem.study.R;
import com.lockmem.study.StudyActivity;

import com.lockmem.constants.MyActivity;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ProgressBar;
import android.widget.TextView;

public class StatisticActivity extends MyActivity {
	private ImageButton btnSetting ;
	private String tag = "StatisticActivity";
	private TextView tvtoday,tvtotal,tvgot,tvremain;
	private String current_tablename = "t_words";
	private RowUserData rowUserData = null ;
	private ProgressBar progressBar;
	private TextView fenmuText,fenziText;
	private Button repeat ;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
		setContentView(R.layout.activity_statistics);
		getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.titlebar_sta);
		tvtoday = (TextView)findViewById(R.id.sta_todayunlock);
		progressBar = (ProgressBar)findViewById(R.id.progressBar1);
		tvtotal = (TextView)findViewById(R.id.sta_totalunlock);
		tvgot = (TextView)findViewById(R.id.sta_gotwords);
		fenmuText = (TextView)findViewById(R.id.textView2);
		tvremain = (TextView)findViewById(R.id.sta_remainwords);
		fenziText = (TextView)findViewById(R.id.textView3);
		repeat = (Button)findViewById(R.id.repeatWrong);
		repeat.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent in = new Intent(StatisticActivity.this,StudyActivity.class);
				in.putExtra("repeat", true);
				startActivity(in);
			}
		});
		btnSetting = (ImageButton)findViewById(R.id.imageButton1);
		btnSetting.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				StatisticActivity.this.startActivity(new Intent(StatisticActivity.this,SettingActivity.class));
			}
		});
	}

	@Override
	public void init() {
		// TODO Auto-generated method stub
		rowUserData =ser.getUserData(current_tablename);
		int learned = rowUserData.value_learned_items;
		int unlearned = rowUserData.value_unlearned_items;
		tvtoday.setText(String.format("%d", rowUserData.value_today_unlock_times));
		tvtotal.setText(String.format("%d",rowUserData.value_unlock_times));
		tvgot.setText(String.format("%d", learned));
		tvremain.setText(String.format("%d",unlearned));
		progressBar.setMax(learned+unlearned);
		progressBar.setProgress(learned);
		fenmuText.setText("/"+ String.valueOf(learned+unlearned));
		fenziText.setText(String.valueOf(learned));
	}
	
	@Override
	public void setTheme() {
		// TODO Auto-generated method stub
		if(ser.getSkin()==ConfValue.Skin_Pink)
			return ;
		turnBoyTheme(R.id.stalay,4);
		turnBoyTheme(R.id.stabkg, 0);
		turnBoyTheme(R.id.RelativeLayout1, 1);
		turnBoyTheme(R.id.RelativeLayout2, 2);
		turnBoyTheme(R.id.RelativeLayout3, 3);
		turnBoyTheme(R.id.RelativeLayout4, 4);
		
	}
}
